/**
 * HexEncoder.java
 * com.sitech.util.password
 * Function： TODO 
 *
 *   ver  author   date    
 * ──────────────────────────────────
 *   	 geutopia  Feb 11, 2011        
 *
 * Copyright (c) 2011, TNT All Rights Reserved.
*/

package com.sitech.util.password;

import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;

/**
 * ClassName:HexEncoder
 * Function: TODO ADD FUNCTION
 * Reason:	 TODO ADD REASON
 *
 * @author   geutopia
 * @version  
 * @since    Ver 1.1
 * @Date	 2011	Feb 11, 2011		2:51:06 PM
 *
 * @see 	 
 */

public class HexEncoder implements PasswordEncoder
{

	/**
	 * (non-Javadoc)
	 * @see com.sitech.util.password.PasswordEncoder#decode(java.lang.String)
	 */
	public String decode(String codeSting)
	{
		Hex hex = new Hex();
		try
		{
			byte[] bytes = hex.decode(codeSting.getBytes());
			return new String(bytes);
		}
		catch (DecoderException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * (non-Javadoc)
	 * @see com.sitech.util.password.PasswordEncoder#encode(java.lang.String)
	 */
	public String encode(String uncodeString)
	{
		Hex hex = new Hex();
		String codeString = hex.encodeHexString(uncodeString.getBytes());
		return codeString;
	}

	public static void main(String[] args) {
		HexEncoder end = new HexEncoder();
		System.out.println(end.encode("bnms10"));
	}
}
